<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>问题操作</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!-- 引入css -->
<link href="/ksp/layui/css/layui.css" rel="stylesheet">
<!-- 引入js -->
<script type="text/javascript" src="/ksp/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/ksp/layui/layui.all.js"></script>
<script type="text/javascript" src="/ksp/js/ksp.com.js"></script>
<script type="text/javascript" src="/ksp/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/ksp/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" src="/ksp/ueditor/lang/zh-cn/zh-cn.js"></script>
<!-- 自定义js -->
<script type="text/javascript">
	var oprTyp;
	var tskTch;
	var element;
	var form;
	layui.use(['element', 'form' ], function() {
		element = layui.element;
		form = layui.form;
	});

	function iniUeditor() {
		UE.getEditor("KSP_CON", {
			toolbars : [[ 'source', '|', 'undo', 'redo', '|',
			/* 'fullscreen', 
			'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
			'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
			'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
			'directionalityltr', 'directionalityrtl', 'indent', '|',
			'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
			'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
			 */
			'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo',
			/* 'music', 
			'attachment',  */
			/* 'map', 'gmap', 'insertframe', */
			'insertcode'
			/* 'webapp', 'pagebreak', 'template', 'background', '|', */
			/* 'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
			'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
			'print', 'preview', 'searchreplace', 'help', 'drafts'
			 */
			] ],
			elementPathEnabled : false,
			wordCount : true,
			serverUrl : "/ksp/uedi",
			zIndex : 0
		});

		UE.getEditor("SPC_RMK", {
			toolbars : [[ 'source', '|', 'undo', 'redo', '|',
			/* 'fullscreen', 
			'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
			'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
			'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
			'directionalityltr', 'directionalityrtl', 'indent', '|',
			'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
			'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
			 */
			'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo',
			/* 'music', 
			'attachment',  */
			/* 'map', 'gmap', 'insertframe', */
			'insertcode'
			/* 'webapp', 'pagebreak', 'template', 'background', '|', */
			/* 'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
			'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
			'print', 'preview', 'searchreplace', 'help', 'drafts'
			 */
			]],
			elementPathEnabled : false,
			wordCount : true,
			serverUrl : "/ksp/uedi",
			zIndex : 0
		});
	}

	function iniForm() {
		oprTyp = getUrlPam("t");
		tskTch = getUrlPam("id");

		/* 人员下拉框 */
		$.ajax({
			url : "/ksp/usr/KSPU05",
			type : "get",
			dataType : "json",
			data : {
				"COO_TKN" : getCookie("COO_TKN")
			},
			success : function(res) {
				if (res.cod == "200") {
					var ops = "";
					var deaUsrArr = eval(res.jdt);
					for (var i = 0; i < deaUsrArr.length; i++) {
						var u = deaUsrArr[i];
						ops += '<option value="' + u.USR_OAM + '">' + u.USR_NAM
								+ '</option>'
					}
					$("#DEA_USR").append(ops);
					form.render();
				} else {
					alert(res.msg);
				}
			}
		});

		if (oprTyp == "e") {
			$("#tType").html("编辑");
			EditForm(tskTch);
		} else {
			$("#tType").html("新增");
			$("#divRmk").hide();
		}
	}

	function EditForm(tskTch) {
		$.ajax({
			url : "/ksp/tsk/KSPT03",
			type : "post",
			dataType : "json",
			data : {
				"TCH_IDN" : tskTch
			},
			success : function(res) {
				if (res.cod == "200") {
					var tskArr = eval(res.jdt);
					var tsk = tskArr[0];
					$("#KSP_TTL").val(tsk.KSP_TTL).attr("disabled", true);
					var ueKspCon = UE.getEditor('KSP_CON');
					ueKspCon.ready(function() {
						ueKspCon.setContent(tsk.KSP_CON);
					});
					
					var rmk = UE.getEditor('SPC_RMK');
					rmk.ready(function() {
						rmk.setContent(tsk.SPC_RMK);
					});
					
					$("#TSK_TYP").val(tsk.TSK_TYP);
					$("#IMP_DEG").val(tsk.IMP_DEG);
					$("#DEA_USR").val(tsk.DEA_USR);
					form.render();
				}
			}
		});
	}

	function iniBtnFnc() {
		//提交
		$("#bTesst").click(function() {
			var KSP_TTL = $("#KSP_TTL").val();
			var KSP_CON = UE.getEditor("KSP_CON").getContent();
			var IMP_DEG = $("#IMP_DEG").val();
			var DEA_USR = $("#DEA_USR").val();
			var DEA_UNM = $("#DEA_USR").find("option:selected").text();
			var TSK_TYP = $("#TSK_TYP").val();
			var SPC_RMK = UE.getEditor("SPC_RMK").getContent();
			var QUA_UNM = $("#QUA_UNM").val();
			var TCH_IDN = tskTch;
			var reqUpd = {
					"KSP_CON" : KSP_CON,
					"IMP_DEG" : IMP_DEG,
					"DEA_USR" : DEA_USR,
					"DEA_UNM" : DEA_UNM,
					"TSK_TYP" : TSK_TYP,
					"SPC_RMK" : SPC_RMK,
					"TCH_IDN" : TCH_IDN
				};
			
			$.ajax({
				url : "/ksp/tsk/KSPT05"
				,type : "post"
				,dataType : "json"
				,data : reqUpd
				,success : function(res) {
					if (res.cod == "200") {
						tskLst = eval(res.jdt);
						window.location.href = "/ksp/p/tsk/tsklst";
					} else {
						alert(res.msg);
					}
					//showDtabyTyp("fir");
				}
			});
			
		});
		
		$("#bAdd").click(function() {
			
			var reqDta;
			var oprUrl = "";
			var tskmsg = "";
			if (oprTyp == "e") {
				
				/* oprUrl = "";
				reqDta = reqUpd;
				$.ajax({
					url : oprUrl,
					type : "post",
					dataType : "json",
					data : reqDta,
					async : false,
					success : function(res) {
						if (res.cod == "200") {
							alert("执行成功");
							window.location.href = "/ksp/p/tsk/tsklst";
						} else {
							alert(res.msg);
						}
					}
				}); */
			} else {
				var reqIns = {
						"COO_TKN" : getCookie("COO_TKN"),
						"KSP_TTL" : KSP_TTL,
						"KSP_CON" : KSP_CON,
						"IMP_DEG" : IMP_DEG,
						"DEA_USR" : DEA_USR,
						"DEA_UNM" : DEA_UNM,
						"TSK_TYP" : TSK_TYP
					};
				oprUrl = "/ksp/tsk/KSPT01";
				reqDta = reqIns;
				$.ajax({
					url : oprUrl,
					type : "post",
					dataType : "json",
					data : reqDta,
					async : false,
					success : function(res) {
						if (res.cod == "200") {
							alert("执行成功");
							window.location.href = "/ksp/p/tsk/tsklst";
						} else {
							alert(res.msg);
						}
					}
				});
			}
		});
	}
</script>
<script type="text/javascript">
	$(function() {
		iniNar();
		iniUeditor();
		iniForm();
		iniBtnFnc();
	})
</script>

</head>
<body>
	<div id="navDiv"></div>
	<div
		style="margin-top: 20px; margin-left: 20px; width: 1300px; height: 100%;">
		<div style="background-color: #eff;">
			<a href="/ksp/index">首页</a>-><a href="/ksp/p/tsk/tsklst">问题反馈</a> -><span
				id="tType"></span>
		</div>

		<form class="layui-form" style="padding-top: 20px;">
			<div class="layui-form-item">
				标题<input class="layui-input" name="KSP_TTL" id="KSP_TTL" required
					lay-verify="required" placeholder="简洁描述你的问题" autocomplete="off">
			</div>
			<div class="layui-form-item">
				内容
				<textarea id="KSP_CON" name="KSP_CON" style="height: 400px;"></textarea>
			</div>
			<div>
				<label>任务类型</label>
				<div class="layui-inline">
					<select id="TSK_TYP" style="width: 50px;">
						<option value="1" selected="true">工作平台</option>
						<option value="2">自动发布工具</option>
						<option value="3">微服务</option>
						<option value="4">其他</option>
					</select>
				</div>
				&nbsp;&nbsp; <label>重要级别</label>
				<div class="layui-inline">
					<select id="IMP_DEG" style="width: 50px;">
						<option value="1">高</option>
						<option value="2" selected="true">中</option>
						<option value="3">低</option>
					</select>
				</div>
				&nbsp;&nbsp; <label>处理人员</label>
				<div class="layui-inline">
					<select id="DEA_USR" style="width: 90px;">
					</select>
				</div>
			</div>

			<div class="layui-form-item" id="divRmk">
				解决方法
				<textarea id="SPC_RMK" name="SPC_RMK" style="height: 200px;"></textarea>
			</div>
			<div style="padding-top: 5px;">
			<button class="layui-btn" data-type="qryTskLst" id="bAdd">提交</button>
			<button class="layui-btn" data-type="qryTskLst" id="bTesst">提交test</button>
			</div>
		</form>
	</div>
</body>
</html>
